package com.jiayang

import android.content.Context
import android.content.Intent
import androidx.fragment.app.Fragment
import com.google.auto.service.AutoService
import com.jiayang.common.autoservice.MyWebViewService

/**
 * @ClassName MyWebViewServiceImpl
 * @Author JIAYANG
 * @Date 2022/4/22 20:37
 * @Email 1354856871@qq.com
 */
@AutoService(MyWebViewService::class)
class MyWebViewServiceImpl : MyWebViewService {
    override fun startWebViewActivity(context: Context, url: String,title : String,isShowActionBar : Boolean,isNativeRefresh: Boolean) {
        val intent = Intent(context, MyWebViewActivity::class.java)
        intent.putExtra(WEBVIEW_ACTIVITY_URL, url)
        intent.putExtra(WEBVIEW_ACTIVITY_TITLE, title)
        intent.putExtra(WEBVIEW_ACTIVITY_URL_IS_SHOW_ACTIONBAR, isShowActionBar)
        intent.putExtra(WEBVIEW_FRAGMENT_CAN_NATIVE_REFRESH, isNativeRefresh)
        context.startActivity(intent)
    }

    override fun getWebViewFragment(url: String, isNativeRefresh: Boolean): Fragment {
        return MyWebViewFragment.newInstance(url,isNativeRefresh)
    }

}